<style >
  table.formTable {
    font-family: verdana, arial, sans-serif;
    font-size: 0.875rem;
    color: #333333;
    border-width: 0px;
    border-color: #dcdfe6;
    border-collapse: collapse;
    width: 100%;
  }

  table.formTable td {
    border-width: 0px;
    padding: 20px;
    border-style: solid;
    border-color: #dcdfe6;
    background-color: #ffffff;
    padding:2px;
    text-align: center;
  }

  table.formTable td:first-child {
    width: 100px;
    text-align: right;
  }

  table.formTable td:last-child {
  	/*  color: #E6A23C;  */
  }
  
      #tableIconForBizStylePoint + .layui-table-view .layui-table-body tbody > tr > td {
        padding: 0;
    }

    #tableIconForBizStylePoint + .layui-table-view .layui-table-body tbody > tr > td > .layui-table-cell {
        height: 60px;
        line-height: 60px;
    }

    .tdImg {
        width: 35px;
        height:35px;
        max-width: none;
        cursor: pointer;
    }

    .layui-table-view {
        margin: 0;
    }
    #tableBizStylePosition + .layui-table-view .layui-table-body tbody > tr > td {
        padding: 0;
    }

    #tableBizStylePoint + .layui-table-view .layui-table-body tbody > tr > td > .layui-table-cell {
        height: auto;
        line-height: 30px;
        padding: 0 5px;
    }

    .tdImg {
        width: 35px;
        max-width: none;
        cursor: pointer;
    }

    .layui-table-view {
        margin: 0;
    } 
    
</style>
<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body table-tool-mini">
            <div class="layui-form toolbar" id="tbToolBar">
                <div class="layui-form-item">
					<div class="layui-inline">
						<button id="btnAddBizStylePosition" class="layui-btn icon-btn"><i class="layui-icon">&#xe654;</i>新增</button>
					</div>
                    <div class="layui-inline" style="float: right;margin-right: 0px;">
						<div class="layui-inline" style="padding-right: 0px;margin-right: 0px;">
							<label class="layui-form-label w-auto">名称</label>
							<div class="layui-input-inline mr0">
								<input name="name" class="layui-input" type="text" placeholder="请输入名称"/>
							</div>
						</div>
						<div class="layui-inline" style="padding-right: 0px;margin-right: 0px;">
							<button class="layui-btn icon-btn" lay-filter="formSubSearchBizStylePoint" lay-submit>
								<i class="layui-icon">&#xe615;</i>查询
							</button>
						</div>					
					</div>
				</div>
				<table class="layui-table" id="tableBizStylePosition" lay-filter="tableBizStylePosition"></table>
			</div>
		</div>
	</div>
</div>

<!-- 表格操作列 -->
<script type="text/html" id="tableBarBizStylePoint">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<!-- 表格状态列 -->
<script type="text/html" id="tableStateBizStylePoint">
#[[  {{#  if(d.status === '1'){ }}
    <span style="color: #23aa2e;">正常</span>
  {{#  } else { }}
	<span style="color: #ff0000;">禁止</span>
  {{#  } }}
]]#
	</script>


<!-- 表单弹窗-->
<script type="text/html" id="modelBizStylePoint"> 
  <form id="modelBizStylePointPositionForm" lay-filter="modelBizStylePointPositionForm" class="layui-form model-form" style="padding: 0px;">
	 <div class="layui-form-item">
		<table class="formTable">
			<tr>
				<td colspan="4" style="text-align: left;">点位置样式名称</td>   <input name="id" type="hidden"/>
			</tr>
			<tr>
				<td colspan="2">
			        <input  name="name"   placeholder="请输入名称" type="text" class="layui-input" />
			    </td>

			</tr>
			<tr>
				<td colspan="2" style="text-align: left;">可视范围</td>
				<td colspan="2" style="text-align: left;">偏移</td>
			</tr>

			<tr>
				<td >
			        <input name="displayNear" autocomplete="off"  placeholder="请输入近" type="text" class="layui-input" />
			    </td>
				<td >
			        <input name="displayFar" autocomplete="off"  placeholder="请输入远" type="text" class="layui-input" />
			    </td>
				<td >
			        <input name="pixelOffsetX" autocomplete="off" value="0"  placeholder="请输入近" type="text" class="layui-input" />
			    </td>
				<td>
			        <input name="pixelOffsetY" autocomplete="off" value="0"  placeholder="请输入远" type="text" class="layui-input" />
			    </td>
			</tr>
			<tr>
				<td colspan="4" style="text-align: left;">距离缩放</td>
			</tr>
			<tr>
				<td>
			        <input name="scalarNear" autocomplete="off" placeholder="请输入近" type="text" class="layui-input" />
			    </td>
				<td >
					<input name="scalarNearValue" autocomplete="off" placeholder="请输入值(近)" type="text" class="layui-input" />
				</td>
				<td >
			     	<input name="scalarFar" autocomplete="off" placeholder="请输入远" type="text" class="layui-input" />
			   	</td>
				<td>
			     	<input name="scalarFarValue" autocomplete="off" placeholder="请输入值(远)" type="text" class="layui-input" />
			    </td>
			</tr>
			<tr>
				<td colspan="4" style="text-align: left;">距离透明度</td>
			</tr>
			<tr>
				<td>
			        <input name="translucencyNear" autocomplete="off"  placeholder="请输入近" type="text" class="layui-input" />
			    </td>
				<td >
			        <input name="translucencyNearValue" autocomplete="off"  placeholder="请输入值(近)" type="text" class="layui-input" />
			    </td>
				<td>
			        <input name="translucencyFar" autocomplete="off"  placeholder="请输入远" type="text" class="layui-input" />
			    </td>
				<td>
			        <input name="translucencyFarValue" autocomplete="off"  placeholder="请输入值(远)" type="text" class="layui-input" />
			    </td>

			</tr>
			<tr>
				<td colspan="4" style="text-align: left;">距离偏移</td>
			</tr>
			<tr>
				<td>
			        <input name="pixelOffsetScaleNear" autocomplete="off"  placeholder="请输入近" type="text" class="layui-input" />
			    </td>
				<td>
			        <input name="pixelOffsetScaleNearValue" autocomplete="off"  placeholder="请输入值(近)" type="text" class="layui-input" />
			    </td>
				<td>
			        <input name="pixelOffsetScaleFar" autocomplete="off"  placeholder="请输入远" type="text" class="layui-input" />
			    </td>
				<td>
			        <input name="pixelOffsetScaleFarValue" autocomplete="off"  placeholder="请输入值(远)" type="text" class="layui-input" />
			    </td>
			</tr>
		</table>    
	</div>
	<div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            <button class="layui-btn" lay-filter="modelSubmitBizStylePointPosition" lay-submit>保存</button>
     </div>
</form>
</script>
 

<!-- js部分 -->
<script>
    layui.use(['layer', 'form', 'table', 'util', 'admin', 'config','colorpicker'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var util = layui.util;
        var admin = layui.admin;
        var config = layui.config;
        var colorpicker = layui.colorpicker;
        // 渲染表格
        var insTb = table.render({
            elem: '#tableBizStylePosition',
            url: '#(ctx)/biz/style/point/position/listData', 
            page: true,
            toolbar: false,
            cellMinWidth: 100,
            cols: [[
               
                {field: 'name', sort: false, title: '名称'},
                {
                    field: 'createTime', sort: false, templet: function (d) {
                        return util.toDateString(d.createTime);
                    }, title: '创建时间'
                },
				{field: 'status', sort: false, templet: '#tableStateBizStylePoint', title: '状态', align: 'center'},
                {align: 'left', toolbar: '#tableBarBizStylePoint', title: '操作'}
            ]],
        });

        // 添加
		$('#btnAddBizStylePosition').click(function () {
			 showEditModel();
		});

        // 搜索
        form.on('submit(formSubSearchBizStylePoint)', function (data) {
            insTb.reload({where: data.field}, 'data');
        });

        // 工具条点击事件
        table.on('tool(tableBizStylePosition)', function (obj) {
            var data = obj.data;
            var layEvent = obj.event;
            if (layEvent === 'edit') { // 修改
            	showEditModel(data);
            } else if (layEvent === 'del') { // 删除
                doDel(data.id, data.name);
            }
            
            
        });

        // 删除
        function doDel(id, name) {
            layer.confirm('确定要删除“【<span style="color:red;">' + name + '</span>】”吗？', {
                skin: 'layui-layer-admin',
                shade: .1
            }, function (i) {
                layer.close(i);
                layer.load(2);
                admin.req('biz/style/point/position/delete', {
                    id: id
                }, function (res) {
                    layer.closeAll('loading');
                    if (res.code == 200) {
                        layer.msg(res.message, {icon: 1});
                        insTb.reload({}, 'data');
                    } else {
                        layer.msg(res.message, {icon: 2});
                    }
                }, 'get');
            });
        }
        
         

        // 显示表单弹窗
        function showEditModel(data) {
            layer.open({
                type: 1,
                shade: 0.3,
                offset: 't'	,
                title: (data ? '修改' : '添加') + '',
                area:'500px',
                resize :false,
                content: $('#modelBizStylePoint').html(),
                success: function (layero, dIndex) {
                    $(layero).children('.layui-layer-content').css('overflow', 'visible');
                    form.val('modelBizStylePointPositionForm', data);  // 回显数据
                	     
    			    form.on('submit(modelSubmitBizStylePointPosition)', function (data) {
    			        layer.load(2);
    			        var formData={}; 
    			        
    			        for(var key in data.field){
    			        	formData['bizStylePointPosition.'+key]=data.field[key];
    			        }
    			      
                        admin.req("biz/style/point/position/save",formData, function (res) {
                            layer.closeAll('loading');
                            if (res.code == 200) {
                                layer.close(dIndex);
                                layer.msg(res.message, {icon: 1});
                                insTb.reload({}, 'data');
                            } else {
                                layer.msg(res.message, {icon: 2});
                            }
                        }, 'post');
    			        return false;
    			    });
    			    form.render(); 
                },
                end:function(){
                }
            });
        }
        
        

    });
</script>
